package JFrame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

// 用户总功能界面
public class UserJFrame extends JFrame implements ActionListener {
    JButton btnTimeDeposit = new JButton("定期存款");
    JButton btnDemandDeposit = new JButton("活期存款");
    JButton btnQueryRecords = new JButton("查询功能");
    JButton btnTakeMoney = new JButton("取款功能");
    JButton btnTransferAccount = new JButton("转账功能");

    // 用户界面设置
    public UserJFrame(){
        this.setName("村镇银行业务储蓄系统");
        this.setTitle("用户操作界面");
        this.setSize(500, 200);
        this.setAlwaysOnTop(true);
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(2);
        this.setLayout(new FlowLayout());

        JPanel p1 = new JPanel();
        p1.add(btnTimeDeposit);
        p1.add(btnDemandDeposit);
        p1.add(btnQueryRecords);
        p1.add(btnTakeMoney);
        p1.add(btnTransferAccount);

        this.add(p1);
        btnTimeDeposit.addActionListener(this);
        btnDemandDeposit.addActionListener(this);
        btnTakeMoney.addActionListener(this);
        btnQueryRecords.addActionListener(this);
        btnTransferAccount.addActionListener(this);
        this.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // 进入定期存款界面
        if(e.getSource() == btnTimeDeposit) {
            TimeDepositJFrame timeDepositJFrame = new TimeDepositJFrame();
        }
        // 进入活期存款界面
        if(e.getSource() == btnDemandDeposit) {
            DemandDepositJFrame demandDepositJFrame = new DemandDepositJFrame();
        }
        // 进入查询功能界面
        if(e.getSource() == btnQueryRecords) {
            QueryJFrame queryJFrame = new QueryJFrame();
        }
        // 进入取款功能界面
        if(e.getSource() == btnTakeMoney) {
            WithdrawalJFrame withdrawalJFrame = new WithdrawalJFrame();
        }
        if(e.getSource() == btnTransferAccount) {
            new TransferJFrame();
        }
    }
}
